package com.danbay.cloud.base.constants;


/**
 * 用户角色枚举
 *
 * @author SJG
 *         2018/01/11
 */
public enum Roles {
    ADMIN("admin", "管理员"),
    EMPLOYEE("employee", "公寓方员工"),
    ENGINEERING("engineering", "工程员"),
    ENTERPRISE("enterprise", "公寓方企业"),
    FOREIGN("foreign", "外协"),
    OPERATION("operation", "运维"),
    PLATFORM("platform", "平台管理员"),
    RENTER("renter", "租客"),
    SALES("sales", "销售"),
    SETTER("setter", "安装员"),
    THIRDPART("thirdpart", "第三方平台");

    private final String roleName;
    private final String phrase;

    Roles(String roleName, String phrase) {
        this.roleName = roleName;
        this.phrase = phrase;
    }

    public String roleName() {
        return roleName;
    }

    public static Roles parse(String roleName) {
        switch (roleName) {
            case "admin":
                return ADMIN;
            case "employee":
                return EMPLOYEE;
            case "engineering":
                return ENGINEERING;
            case "enterprise":
                return ENTERPRISE;
            case "foreign":
                return FOREIGN;
            case "operation":
                return OPERATION;
            case "platform":
                return PLATFORM;
            case "renter":
                return RENTER;
            case "sales":
                return SALES;
            case "setter":
                return SETTER;
            case "thirdpart":
                return THIRDPART;
            default:
                return EMPLOYEE;
        }
    }

    public String getPhrase() {
        return phrase;
    }
}